import {
  createRouter,
  createWebHistory,
  createWebHashHistory
} from "vue-router"; 
// import routes from './routes'
import {useStore} from '../store/useStore'
import { tabPaneProps } from "element-plus";

// 无需登录即可访问的路由
const initRoutes = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/index.vue"),
  },
  {
    path:"/demo",
    name:"demo",
    component: () => import("@/views/demo/demo1.vue"),

  }
]

const router = createRouter({
  history: createWebHistory(),
  //初始只展示不用登录所能展示的页面
  routes:initRoutes,
});


// let whiteList = ['/login','/demo'];

// // 路由守卫
// router.beforeEach((to,from,next)=>{
//   const store = useStore();
//   //已经登陆
//   if(store.isLogin){
//     if(to.path==='/login'){
//       next('/home')
//     }else{
//       next()
//     }
//   }else{
//     if(whiteList.includes(to.path)){
//       next()
//     }else{
//       next('/login')
//     }
//   }
// })


export default router;